/*
* @Description: 公共gis配置
 * @Author: Liu Zhiwang
 * @Date: 2021-03-27 14:34:16
 * @LastEditTime: 2021-03-29 14:09:55
 * @LastEditors: Liu Zhiwang
 */
var tyeMapConf = function() {
  const isEnvConf = true
  const vaab = 'http://172.20.1.9:13772/arcgis/'
  // arcgis js api 基础地址
  const arcgis_js = isEnvConf?vaab.slice(0,vaab.length-1)+'_js_api':
  'http://172.20.1.9:13772/arcgis_js_api'
  function loadCss() {
    const url = arcgis_js + '/4x/latest/esri/themes/light/main.css'
    var link = document.createElement('link')
    link.setAttribute('rel', 'stylesheet')
    link.setAttribute('type', 'text/css')
    link.setAttribute('href', url)
    document.documentElement.appendChild(link)
  }
  // 底图配置
  const maps = [{
    'code': 'IMG',
    'title': '卫星',
    'icon': '/images/basemap_IMG.png',
    'layers': [{
      'layerType': 'WMTS',
      'url': isEnvConf?(vaab+'rest/services/BASE_IMG_W/MapServer/WMTS'):'http://172.20.1.9:13772/arcgis/rest/services/BASE_IMG_W/MapServer/WMTS'
    }]
  }, {
    'code': 'IMGANNO',
    'title': '卫星标签',
    'icon': '/images/basemap_IMGANNO.png',
    'layers': [{
      'layerType': 'WMTS',
      'url': isEnvConf?(vaab+'rest/services/BASE_IMG_W/MapServer/WMTS'):'http://172.20.1.9:13772/arcgis/rest/services/BASE_IMG_W/MapServer/WMTS'
    }, {
      'layerType': 'WMTS',
      'url': isEnvConf?(vaab+'rest/services/BASE_CIA_W/MapServer/WMTS'):'http://172.20.1.9:13772/arcgis/rest/services/BASE_CIA_W/MapServer/WMTS'
    }]
  }, {
    'code': 'SIM',
    'title': '简易',
    'icon': '/images/basemap_SIM.png',
    'layers': [{
      'layerType': 'MapService',
      'url': isEnvConf?(vaab+'rest/services/BASE_SIM_W/MapServer'):'http://172.20.1.9:13772/arcgis/rest/services/BASE_SIM_W/MapServer'
    }]
  }]
  // 常量 不需要修改
  const lods = [
    { 'level': 1, 'scale': 295828763.79577702, 'resolution': 78271.516963999937 },
    { 'level': 2, 'scale': 147914381.89788899, 'resolution': 39135.758482000092 },
    { 'level': 3, 'scale': 73957190.948944002, 'resolution': 19567.879240999919 },
    { 'level': 4, 'scale': 36978595.474472001, 'resolution': 9783.9396204999593 },
    { 'level': 5, 'scale': 18489297.737236001, 'resolution': 4891.9698102499797 },
    { 'level': 6, 'scale': 9244648.8686180003, 'resolution': 2445.9849051249898 },
    { 'level': 7, 'scale': 4622324.4343090001, 'resolution': 1222.9924525624949 },
    { 'level': 8, 'scale': 2311162.2171550002, 'resolution': 611.49622628137968 },
    { 'level': 9, 'scale': 1155581.108577, 'resolution': 305.74811314055756 },
    { 'level': 10, 'scale': 577790.55428899999, 'resolution': 152.87405657041106 },
    { 'level': 11, 'scale': 288895.27714399999, 'resolution': 76.437028285073239 },
    { 'level': 12, 'scale': 144447.638572, 'resolution': 38.21851414253662 },
    { 'level': 13, 'scale': 72223.819285999998, 'resolution': 19.10925707126831 },
    { 'level': 14, 'scale': 36111.909642999999, 'resolution': 9.5546285356341549 },
    { 'level': 15, 'scale': 18055.954822, 'resolution': 4.7773142679493699 },
    { 'level': 16, 'scale': 9027.9774109999998, 'resolution': 2.3886571339746849 },
    { 'level': 17, 'scale': 4513.9887049999998, 'resolution': 1.1943285668550503 },
    { 'level': 18, 'scale': 2256.994353, 'resolution': 0.59716428355981721 }
  ]
  return {
    fonts: arcgis_js + '/fonts/',
    jsapi: arcgis_js + '/4x/latest/init.js',
    importArcgisCss: loadCss,
    geometryServiceUrl: isEnvConf?(vaab+'rest/services/Utilities/Geometry/GeometryServer'):'http://172.20.1.9:13772/arcgis/rest/services/Utilities/Geometry/GeometryServer',
    arcgisServer: isEnvConf?vaab.slice(0,vaab.length-1):'http://172.20.1.9:13772/arcgis',
    arcgis_auth_acount: '',
    center: [113.26715, 23.08258],
    zoom: 6,
    lods: lods,
    minZoom: 6,
    maxZoom: 17,
    validExtent: { 'xmin': 106.7857, 'ymin': 18.4361, 'xmax': 121.6173, 'ymax': 30.8817, 'spatialReference': { 'wkid': 4326 }},
    wmtsServiceMode: 'KVP',
    basemaps: maps,
    cadBase: '',
    cadService_dic: '12300105|12300105,12300106|12300106,12300164|12300164'
  }
}
